using System;
using System.Collections;
using System.Data;
using System.Drawing;
using System.Windows.Forms;


using C1.Win.C1Input;
using C1.Win.C1List;
using C1.Win.C1TrueDBGrid;
using C1.Win.C1Command;
using AlignHorzEnum = C1.Win.C1TrueDBGrid.AlignHorzEnum;
using AlignVertEnum = C1.Win.C1TrueDBGrid.AlignVertEnum;
using C1DisplayColumn = C1.Win.C1TrueDBGrid.C1DisplayColumn;
using CancelEventHandler = System.ComponentModel.CancelEventHandler;


using GURUCORE.Service /*####Admin*/;
using GURUCORE.DTO; /*###AdminDTO*/
using GURUCORE.Common;
using GURUCORE.GException.Service;
using GURUCORE.GException;//###Exception//;
using GURUCORE.Admin;
using GURUCORE.Log;




namespace GURUCORE.FormBase
{	
	public class Security
	{
		const string THIS = "GURUCORE.Util.Security";
		const string CHARA = "@";
		const string CBOCCN = "cboCCN";
		/// <summary>
		/// This message was used for only Super admin account so that no need to add into database
		/// </summary>
		const string MESSAGE_CREATE_DATA_VISIBILITY = "Do you want create data for visibility?";
		/// <summary>
		/// 31 = 2^5-1
		/// </summary>
		const int FULL_PERMISSION = 31;

		
		
		public Security()
		{		
		}
		


	
		/// <summary>
		/// Find control in form by control's name
		/// </summary>
		/// <param name="pForm"></param>
		/// <param name="pControlName"></param>
		/// <returns></returns>
		private Control FindControlByName(Form pForm, string pControlName)
		{
			Control ctl = pForm;
			while(ctl != null)
			{
				ctl = pForm.GetNextControl(ctl, true);
				if (ctl != null)
				{
					if (ctl.Name == pControlName)
					{
						return ctl;
					}
				}
			}
			return null;
		}
			
		/// <summary>
		/// Find button by Name		
		/// </summary>
		/// <param name="pForm"></param>
		/// <param name="pControlName"></param>
		/// <returns></returns>
		private Control FindButtonControlByName(Form pForm, string pControlName)
		{
			Control ctl = FindControlByName(pForm, pControlName);			
			if (ctl != null && ctl is Button)
			{
				return ctl;			
			}
			else 
			{
				return null;
			}
		}

		/// <summary>
		/// DIRTY!
		/// Enable a C1COmbo control on the form
		/// </summary>		
		private void EnabledChanged(object sender, EventArgs e)
		{
			if(sender == null) 
			{
				return;
			}

			C1Combo cboCCN = (C1Combo)sender;
			if (cboCCN.Enabled == false)
			{
				cboCCN.Enabled = true;
			}
		}
		
		
		


	
		/// <summary>
		/// Set all right for a user on form
		/// </summary>
		/// <Inputs>
		/// pForm : the form needs to set
		/// pstrUserName : contains UserName
		/// </Inputs>
		/// <Return>
		/// void
		/// </Return>
		/// <Authors>
		/// TuanDm
		/// </Authors>
		/// <History>
		///	Friday - January 13 - 2005	
		/// </History>
		public int SetRightForUserOnForm(Form pForm, string pstrUserName)
		{
			// SetButtonForRight_View(pForm);
			if(!pForm.Modal)
			{
				bool blnIsFound = false;

				#region Search form which assign security

				for(int intForm = 0; intForm < SystemProperty.ArrayForms.Count; intForm++)
				{
					try
					{
						FormInfo objInforForm = (FormInfo)SystemProperty.ArrayForms[intForm];
						if(objInforForm.mForm == pForm)
						{
							blnIsFound = true;
							break;
						}
					}
					catch
					{
						// do nothing
					}
				}

				#endregion

				if(!blnIsFound)
				{
					#region // if not found add to Array form to manage
					DataRow[] drowMenus = SystemProperty.TableMenuEntry.Select(Sys_Menu_EntryTable.FORMLOAD_FLD + "= '" + pForm.GetType().FullName + "' AND "
						+ Sys_Menu_EntryTable.ISUSERCREATED_FLD + " = 0", Sys_Menu_EntryTable.MENU_ENTRYID_FLD + " ASC");
					FormInfo infoForm;
					if(drowMenus.Length > 0)
					{
						infoForm = new FormInfo(pForm,drowMenus[0][Sys_Menu_EntryTable.PREFIX_FLD].ToString(),
						                        drowMenus[0][Sys_Menu_EntryTable.TRANSFORMAT_FLD].ToString(),
						                        drowMenus[0][Sys_Menu_EntryTable.TABLENAME_FLD].ToString(),
						                        drowMenus[0][Sys_Menu_EntryTable.TRANSNOFIELDNAME_FLD].ToString(),
						                        SystemProperty.UserName);
					}
					else
					{
						infoForm = new FormInfo(pForm,string.Empty,string.Empty,string.Empty,string.Empty,SystemProperty.UserName);
					}
					SystemProperty.ArrayForms.Add(infoForm);

					#endregion
				}
			}

			CommonBO boCommon = new CommonBO();
			// HACK: SonHT 2005-10-13
			//			try
			//			{
			// Sys_RoleDS dsRole = new Sys_RoleDS();
			// END: SonHT 2005-10-13
			DataSet dstSecurity = boCommon.GetSecurityInfo(pstrUserName,pForm.GetType().FullName);
//			if(dstSecurity == null) return FULL_PERMISSION;
//v			DataSet dsRoles = boCommon.ListRoleForUser(pstrUserName);
			int intFullPermission = int.Parse(dstSecurity.Tables[Sys_RightTable.TABLE_NAME].Rows[0][0].ToString());

			#region Deleted

//			int i = 0;
//			string[] strRoleIDs = new string[dsRoles.Tables[0].Rows.Count];
//			// Get Permission from database
//
//			foreach (DataRow drow in dsRoles.Tables[Sys_UserToRoleTable.TABLE_NAME].Rows)
//			{
//				// Get array RoleID
//				strRoleIDs[i++] = drow[Sys_UserToRoleTable.ROLEID_FLD].ToString();
//				// Get full permission
//v				int intProtectObjID = ((Sys_Menu_EntryVO) new CommonBO().GetProtectObjectVO(pForm.Name)).Menu_EntryID;
//				Sys_RightVO voRight = new Sys_RightVO();
//v				voRight = (Sys_RightVO) boCommon.GetRoleObjectVO(int.Parse(drow[Sys_UserToRoleTable.ROLEID_FLD].ToString().Trim()), intProtectObjID);
//				intFullPermission = intFullPermission|voRight.Permission;
//			}

			#endregion

			#region // HACK: Added by Tuan TQ update code to manage super admin user

			if(pstrUserName.Equals(Constants.SUPER_ADMIN_USER))
			{
				// HACK: SONHT HardCode
				DialogResult result = GURUCORE.FormBase.GURUMessageBox.Show(MESSAGE_CREATE_DATA_VISIBILITY,MessageBoxButtons.YesNo,MessageBoxIcon.Question,MessageBoxDefaultButton.Button2);
				if(result == DialogResult.Yes)
				{
					GroupControls frmGroupControl = new GroupControls(pForm);
					//GURUCORE.Admin.GroupControls frmGroupControl = new GroupControls(null);
					frmGroupControl.Show();
					if(pForm.Modal)
					{
						pForm.Show();
					}
				}
				intFullPermission = FULL_PERMISSION;// (2 exp 5) -1
			}

			#endregion

			//End: Added by Tuan TQ 

			#region // if has no permission
			if (intFullPermission == 0)
			{
				// HACK: SonHT 2005-11-09
				//if(dsRoles.Tables[Sys_UserToRoleTable.TABLE_NAME].Rows.Count > 0)
				//Sys_Menu_EntryVO objRight = (Sys_Menu_EntryVO)new CommonBO().GetProtectObjectVO(pForm.Name);
				//DataRow[] drows = SystemProperty.TableMenuEntry.Select(Sys_Menu_EntryTable.FORMLOAD_FLD + "= '" + pForm.Name + "'");
				int intCountExisted = int.Parse(dstSecurity.Tables[Sys_Menu_EntryTable.TABLE_NAME].Rows[0][0].ToString());
				if(intCountExisted > 0)
				{
					return intFullPermission;
				}
				else // If the form does not have script ()
				{
					intFullPermission = FULL_PERMISSION;// (2 exp 5) -1
				}
			}

			#endregion

			// set permission into form
			// SetPermissionForForm(pForm, intFullPermission);
			// Set visible control
			// HACK: SONHT 2005-10-24
//			DataTable dtbTable = (new CommonBO()).GetVisibleControl(pForm.Name,strRoleIDs);
//			DataTable dtbTable = (new VisibilityBO()).GetVisibleControl(pForm.Name,strRoleIDs);
			DataTable dtbTable = dstSecurity.Tables[Sys_VisibilityGroup_RoleTable.TABLE_NAME];
			// Set other property for form
			pForm.StartPosition = FormStartPosition.CenterScreen;
			pForm.KeyPreview = true;


			Control objControl = pForm; 
			#region // Scan control on form to set default property
			while(objControl != null)
			{
				#region // Get next control
				objControl = pForm.GetNextControl(objControl,true);
				if(objControl == null)
				{
					break;
				}

				#endregion

				#region // Set OnEnter and OnLeave
				if (objControl.GetType().Equals(typeof(TextBox)) 
					|| objControl.GetType().Equals(typeof(ComboBox))
					|| objControl.GetType().Equals(typeof(C1Combo)) 
					|| objControl.GetType().Equals(typeof(C1DateEdit))
					|| objControl.GetType().Equals(typeof(C1TextBox)) 
					|| objControl.GetType().Equals(typeof(C1NumericEdit))
					|| objControl.GetType().Equals(typeof(NumericUpDown)) )
				{
					objControl.Enter += new EventHandler(GURUCORE.Lib.OnEnterControl);
					objControl.Leave += new EventHandler(GURUCORE.Lib.OnLeaveControl);
				}

				#endregion

				if(objControl.GetType().Equals(typeof(TextBox)))
				{
					#region // If it's TextBox 
					TextBox txtBox = (TextBox) objControl;
					txtBox.TextAlign = HorizontalAlignment.Left;
					//HACK : TUANDM 18 - 10 - 2005
					txtBox.Text = txtBox.Text.Trim();
					if (txtBox.Text != string.Empty)
					{
						Button btnSearch = (Button) FindButtonControlByName(pForm, txtBox.Text);
						if (btnSearch != null)
						{
							txtBox.Validating += new CancelEventHandler(GURUCORE.Lib.ControlValidating);
							txtBox.Text = string.Empty;
						}
					}

					#endregion

					//END: TUANDM 18 - 10 - 2005
				}
				else if(objControl.GetType().Equals(typeof(C1TextBox)))
				{
					#region C1TextBox
					C1TextBox txtC1Text = (C1TextBox) objControl;
					txtC1Text.TextAlign = HorizontalAlignment.Left;
					//HACK : TUANDM 18 - 10 - 2005
					txtC1Text.Value = txtC1Text.Value.ToString().Trim();
					if (txtC1Text.Value.ToString() != string.Empty)
					{
						Button btnSearch = (Button) FindButtonControlByName(pForm, txtC1Text.Value.ToString());
						if (btnSearch != null)
						{
							txtC1Text.Validating += new CancelEventHandler(GURUCORE.Lib.ControlValidating);
							txtC1Text.Value = string.Empty;
						}
					}

					#endregion
				}
				else if(objControl.GetType().Equals(typeof(C1DateEdit)))
				{
					C1DateEdit dtmC1Date = (C1DateEdit) objControl;
					dtmC1Date.Validated += new EventHandler(GURUCORE.Lib.C1DateEdit_Validated);
					dtmC1Date.TextAlign = HorizontalAlignment.Center;
					dtmC1Date.AcceptsEscape = false;

					#region // Set default dd-MM-yyyy format
					if(dtmC1Date.CustomFormat.Trim().Length == 0)
					{
						dtmC1Date.CustomFormat = Constants.DATETIME_FORMAT;
						dtmC1Date.FormatType = FormatTypeEnum.CustomFormat;
					}
					string strMsg = ErrorMessageBO.GetErrorMessage(ErrorCode.MESSAGE_C1NUMBER_INPUT_VALUE);
					strMsg = strMsg.Replace(CHARA,string.Empty);
					string strSecondMsg = ErrorMessageBO.GetErrorMessage(ErrorCode.MESSAGE_C1NUMBER_OR_MSG);
					// if it has no Intervals
					if (dtmC1Date.PostValidation.Intervals.Count == 0)
					{
						continue;
					}
					foreach (ValueInterval vlInterval in dtmC1Date.PostValidation.Intervals)
					{
						strMsg  += Constants.OPEN_SBRACKET +  vlInterval.MinValue 
							+  Constants.COMMA + Constants.WHITE_SPACE + vlInterval.MaxValue
							+  Constants.CLOSE_SBRACKET + Constants.WHITE_SPACE + strSecondMsg + Constants.WHITE_SPACE;
					}
					strMsg = strMsg.Substring(0, strMsg.Length - strSecondMsg.Length - 1);
					dtmC1Date.ErrorInfo.ShowErrorMessage = true;
					dtmC1Date.ErrorInfo.ErrorMessageCaption = Constants.APPLICATION_NAME;
					dtmC1Date.ErrorInfo.ErrorMessage = strMsg;
					dtmC1Date.ErrorInfo.CanLoseFocus = false;

					#endregion
				}
				else if(objControl.GetType().Equals(typeof(C1NumericEdit)))
				{
					#region // if it is C1NumericEdit
					// TODO: SonHT Set property for C1Num
					C1NumericEdit dtmC1Num = (C1NumericEdit) objControl;
					dtmC1Num.TextAlign = HorizontalAlignment.Right;
					dtmC1Num.AcceptsEscape = false;
					// Set default number format
					if(dtmC1Num.CustomFormat.Trim().Length == 0)
					{
						dtmC1Num.CustomFormat = Constants.DECIMAL_NUMBERFORMAT;
						dtmC1Num.FormatType = FormatTypeEnum.CustomFormat;
					}
					string strMsg = ErrorMessageBO.GetErrorMessage(ErrorCode.MESSAGE_C1NUMBER_INPUT_VALUE);
					strMsg = strMsg.Replace(CHARA,string.Empty); 
					string strSecondMsg = ErrorMessageBO.GetErrorMessage(ErrorCode.MESSAGE_C1NUMBER_OR_MSG);
					// if it has no Intervals
					if (dtmC1Num.PostValidation.Intervals.Count == 0)
					{
						continue;
					}
					foreach (ValueInterval vlInterval in dtmC1Num.PostValidation.Intervals)
					{
						strMsg  += Constants.OPEN_SBRACKET +  vlInterval.MinValue 
							+  Constants.COMMA + Constants.WHITE_SPACE + vlInterval.MaxValue
							+  Constants.CLOSE_SBRACKET + Constants.WHITE_SPACE + strSecondMsg + Constants.WHITE_SPACE;
					}
					strMsg = strMsg.Substring(0, strMsg.Length - strSecondMsg.Length - 1);
					dtmC1Num.ErrorInfo.ShowErrorMessage = true;
					dtmC1Num.ErrorInfo.ErrorMessageCaption = Constants.APPLICATION_NAME;
					dtmC1Num.ErrorInfo.ErrorMessage = strMsg;
					dtmC1Num.ErrorInfo.CanLoseFocus = false;

					#endregion
				}
					
				else if(objControl.GetType().Equals(typeof(C1Combo)))
				{
					#region // if it is C1Combo
					C1Combo cboC1 = (C1Combo) objControl;
					cboC1.DropDownWidth = Constants.DEFAULT_C1COMBO_DROPDOWNWIDTH;
					cboC1.KeyDown += new KeyEventHandler(GURUCORE.Lib.C1Combo_KeyDown);
					cboC1.ComboStyle = ComboStyleEnum.DropdownList;
					// Enable cboCCN control
					if(cboC1.Name == CBOCCN)
					{
						cboC1.Enabled = true;
						cboC1.EnabledChanged += new EventHandler(EnabledChanged);
					}

					#endregion
				}
				else if(objControl.GetType().Equals(typeof(C1TrueDBGrid)))
				{
					#region // if is C1TrueDBGrid control
					C1TrueDBGrid grid = (C1TrueDBGrid) objControl;
					//grid.FilterActive = grid.FilterBar = true;
					grid.RowHeight = Constants.DEFAULT_ROW_HEIGHT;
					grid.MarqueeStyle = MarqueeEnum.HighlightCell;
					grid.HighLightRowStyle.BackColor = Color.FromArgb((byte)Constants.BACKGROUND_COLOUR_R, (byte)Constants.BACKGROUND_COLOUR_G, (byte)Constants.BACKGROUND_COLOUR_B);
					grid.HighLightRowStyle.ForeColor = Color.FromArgb((byte)Constants.FORE_COLOUR_R, (byte)Constants.FORE_COLOUR_R, (byte)Constants.FORE_COLOUR_R);
					grid.Style.VerticalAlignment =  AlignVertEnum.Center;
					if(grid.Splits.Count > 0)
					{
						// Set default alignment
						foreach(C1DisplayColumn c1Column in grid.Splits[0].DisplayColumns)
						{
							c1Column.HeadingStyle.HorizontalAlignment =  AlignHorzEnum.Center;
						}
					}
					// Not allow user change column order
					grid.AllowColMove = false;
					grid.Anchor = AnchorStyles.Left|AnchorStyles.Right|AnchorStyles.Top|AnchorStyles.Bottom;
					// Set Maximize and Resize
					pForm.MaximizeBox = true;
					pForm.FormBorderStyle = FormBorderStyle.Sizable;

					#endregion
				}
			}
			#endregion 
			
			if (!pstrUserName.Equals(Constants.SUPER_ADMIN_USER))
			{
				#region // Scan data from datatable to set visible control
				if(dtbTable != null)
				foreach(DataRow drowData in dtbTable.Rows)
				{
					Control objCon = pForm.GetNextControl(pForm,true);	
					while(objCon != null)
					{
						// if is C1TrueDBGrid control
						if(objCon.GetType().Equals(typeof(C1TrueDBGrid)))
						{
							C1TrueDBGrid grid = (C1TrueDBGrid) objCon;
							// grid.RowHeight = Constants.DEFAULT_ROW_HEIGHT;
							// grid.MarqueeStyle = MarqueeEnum.HighlightRow;
							foreach(C1DisplayColumn objCol in grid.Splits[0].DisplayColumns)
							{
								// do not process if col is invisible
								if(!objCol.Visible)
								{
									objCol.AllowSizing = objCol.Visible = false;
									continue;
								}
								if((objCol.DataColumn.DataField == drowData[Sys_HiddenControlsTable.CONTROLNAME_FLD].ToString().Trim())
									&& (drowData[Sys_VisibilityItemTable.TYPE_FLD].ToString() == VisibilityItemTypeEnum.ColumnTrueDBGrid.GetHashCode().ToString()))
								{
									objCol.AllowSizing = objCol.Visible = false;
								}
							}
						}
							// If control is C1TabControl
						else if(objCon.GetType().Equals(typeof(C1DockingTab)))
						{
							C1DockingTab c1DockingTab = (C1DockingTab) objCon;
							for(int k = 0; k < c1DockingTab.TabCount; k++)
							{
								if(c1DockingTab.TabPages[k].Name == drowData[Sys_HiddenControlsTable.CONTROLNAME_FLD].ToString().Trim()) 
								{
									c1DockingTab.TabPages[k].TabVisible = false;
								}
							}
						}
							// set visible if it is normal control
						else if(objCon.Name == drowData[Sys_HiddenControlsTable.CONTROLNAME_FLD].ToString().Trim()) 
						{
							objCon.Visible = false;
						}
						// Get next control
						objCon = pForm.GetNextControl(objCon,true);
					}
				}
				#endregion 
			}

			// return full permission
			return intFullPermission;

		}
		
		public static bool NoRightToEditTransaction(Form pForm, string pstrPrimaryField,int pintMasterID)
		{
			if(SystemProperty.UserName.ToLower().Equals(Constants.SUPER_ADMIN_USER))
			{
				return false;
			}

			FormInfo formInfor;
			string strTableName = string.Empty;
			for(int i = 0; i < SystemProperty.ArrayForms.Count; i++)
			{
				formInfor = (FormInfo)SystemProperty.ArrayForms[i];
				if(pForm == formInfor.mForm)
				{
					strTableName = formInfor.mTableName;
					break;
				}
			}
			// Check role administrator
			UtilsBO boUtils = new UtilsBO();
			DataSet dstGetRightToModify = boUtils.GetRightToModify(SystemProperty.UserName, strTableName, pstrPrimaryField, pintMasterID);
			if(dstGetRightToModify == null) return false;
			if(int.Parse(dstGetRightToModify.Tables[0].Rows[0][0].ToString()) > 0)
			{
				return false;
			}
			// 
			string strUserCreated = dstGetRightToModify.Tables[1].Rows[0][0].ToString();
			if(!strUserCreated.ToLower().Equals(SystemProperty.UserName.ToLower()))
			{
				GURUCORE.FormBase.GURUMessageBox.Show(ErrorCode.MESSAGE_YOU_DONT_HAVE_RIGHT_TO_EDIT,MessageBoxIcon.Information,new string[] {strUserCreated});
				return true;
			}
			else
			{
				return false;
			}
		}
		
		public static bool IsDifferencePrefix(Form pForm,Label plblTrans, TextBox ptxtTransNo)
		{
			if(SystemProperty.UserName.ToLower().Equals(Constants.SUPER_ADMIN_USER))
			{
				return false;
			}

			FormInfo formInfor;
			string strPrefix = string.Empty;
			for(int i = 0; i < SystemProperty.ArrayForms.Count; i++)
			{
				formInfor = (FormInfo)SystemProperty.ArrayForms[i];
				if(pForm == formInfor.mForm)
				{
					strPrefix = formInfor.mPrefix;
					break;
				}
			}
			if(strPrefix == null || strPrefix == string.Empty) return false;
			if(ptxtTransNo.Text == null) ptxtTransNo.Text = string.Empty;
			ptxtTransNo.Text = ptxtTransNo.Text.ToUpper();
			string strTransNo = string.Empty;
			if(ptxtTransNo.Text.Length >= strPrefix.Length)
			{
				strTransNo = ptxtTransNo.Text.ToLower().Substring(0,strPrefix.Length);
			}
			else
			{
				string[] strTrans = new string[2];
				strTrans[0] = plblTrans.Text;
				strTrans[1] = strPrefix;
				GURUCORE.FormBase.GURUMessageBox.Show(ErrorCode.MESSAGE_TRANSACTION_HAS_TO_HAVE_PREFIX,MessageBoxIcon.Information,strTrans);
				ptxtTransNo.Focus();
				return true;
			}
			if(strPrefix.ToLower().Equals(strTransNo))
			{
				return false;
			}
			else
			{
				string[] strTrans = new string[2];
				strTrans[0] = plblTrans.Text;
				strTrans[1] = strPrefix;
				GURUCORE.FormBase.GURUMessageBox.Show(ErrorCode.MESSAGE_TRANSACTION_HAS_TO_HAVE_PREFIX,MessageBoxIcon.Information,strTrans);
				ptxtTransNo.Focus();
				return true;
			}

		}

		public static bool NoRightToDeleteTransaction(Form pForm, string pstrPrimaryField,int pintMasterID)
		{
			if(SystemProperty.UserName.ToLower().Equals(Constants.SUPER_ADMIN_USER))
			{
				return false;
			}
			FormInfo formInfor;
			string strTableName = string.Empty;
			for(int i = 0; i < SystemProperty.ArrayForms.Count; i++)
			{
				formInfor = (FormInfo)SystemProperty.ArrayForms[i];
				if(pForm == formInfor.mForm)
				{
					strTableName = formInfor.mTableName;
					break;
				}
			}
			// Check role administrator
			UtilsBO boUtils = new UtilsBO();
			DataSet dstGetRightToModify = boUtils.GetRightToModify(SystemProperty.UserName, strTableName, pstrPrimaryField, pintMasterID);
			if(dstGetRightToModify == null) return false;
			if(int.Parse(dstGetRightToModify.Tables[0].Rows[0][0].ToString()) > 0)
			{
				return false;
			}
			// 
			string strUserCreated = dstGetRightToModify.Tables[1].Rows[0][0].ToString();
			if(!strUserCreated.ToLower().Equals(SystemProperty.UserName.ToLower()))
			{
				GURUCORE.FormBase.GURUMessageBox.Show(ErrorCode.MESSAGE_YOU_DONT_HAVE_RIGHT_TO_DELETE,MessageBoxIcon.Information,new string[] {strUserCreated});
				return true;
			}
			else
			{
				return false;
			}	
		}

		public static void UpdateUserNameModifyTransaction(Form pForm, string pstrPrimaryField, int pintMasterID)
		{
			FormInfo formInfor;
			string strTableName = string.Empty;
			for(int i = 0; i < SystemProperty.ArrayForms.Count; i++)
			{
				formInfor = (FormInfo)SystemProperty.ArrayForms[i];
				if(pForm == formInfor.mForm)
				{
					strTableName = formInfor.mTableName;
					break;
				}
			}
			UtilsBO boUtils = new UtilsBO();
			boUtils.UpdateUserNameModifyTransaction(SystemProperty.UserName, strTableName, pstrPrimaryField, pintMasterID);
		}

	}	// end class
	
}	// end namespace